package com.hyfrogx.modules.manage.controller.feedback;

import com.baomidou.mybatisplus.extension.plugins.pagination.Page;
import com.hyfrogx.common.utils.QueryExt;
import com.hyfrogx.common.utils.R;
import com.hyfrogx.modules.manage.controller.BaseController;
import com.hyfrogx.modules.manage.service.feedback.FeedbackService;
import io.swagger.annotations.Api;
import io.swagger.annotations.ApiOperation;
import org.springframework.beans.factory.annotation.Autowired;
import org.springframework.web.bind.annotation.*;

import java.util.Map;
/**
 * @author 罗春杰-技术部
 */
@RestController
@RequestMapping(value = "feedback")
@Api(value = "FeedbackController",tags = {"后台-反馈控制层"})
public class FeedbackController extends BaseController {

    @Autowired
    FeedbackService feedbackService;

    @RequestMapping(value = "getByPage", method = RequestMethod.POST)
    @ApiOperation("获取反馈 分页")
    public R getFeedbackbyPage(@RequestBody Map map) {
        try {
            Page page = feedbackService.findAllFeedbacks(new QueryExt(map));
            return R.ok().put("data", page);
        } catch (Exception e) {
            // TODO: handle exception
            return R.error(e.getMessage());
        }
    }

    /*
     * 删除单条反馈
     */
    @RequestMapping(value = "deleteFeedbackById", method = RequestMethod.POST)
    @ApiOperation("删除反馈")
    public R delectFeedbackById(Integer id) {
        try {
            feedbackService.removeById(id);
            return R.ok("操作成功！");
        } catch (Exception e) {
            return R.error(e.getMessage());
        }
    }





}
